work in progress

Andrew Cantino 11 years ago
parent
commit
d5164ad56b
6 changed files with 47 additions and 17 deletions
  1. 3 0
      .env.example
  2. 1 0
      Gemfile
  3. 4 0
      Gemfile.lock
  4. 8 1
      Procfile
  5. 3 0
      Rakefile
  6. 28 16
      doc/deployment/capistrano/deploy.rb

+ 3 - 0
.env.example

@@ -21,6 +21,9 @@ DATABASE_PASSWORD=
21 21
 
22 22
 # ==== Additional required production settings ====
23 23
 
24
+# Configure Rails environment
25
+RAILS_ENV=development
26
+
24 27
 # Outgoing email settings.  To use Gmail or Google Apps, put your Google Apps domain or gmail.com
25 28
 # as the SMTP_DOMAIN and your Gmail username and password as the SMTP_USER_NAME and SMTP_PASSWORD.
26 29
 SMTP_DOMAIN=your-domain-here.com

+ 1 - 0
Gemfile

@@ -17,6 +17,7 @@ gem "daemons"
17 17
 # gem "delayed_job_web"
18 18
 
19 19
 gem 'foreman'
20
+gem 'dotenv-rails', :groups => [:development, :test]
20 21
 
21 22
 group :assets do
22 23
   gem 'sass-rails',   '~> 3.2.3'

+ 4 - 0
Gemfile.lock

@@ -66,6 +66,9 @@ GEM
66 66
       railties (~> 3.1)
67 67
       warden (~> 1.2.1)
68 68
     diff-lcs (1.2.1)
69
+    dotenv (0.6.0)
70
+    dotenv-rails (0.6.0)
71
+      dotenv (= 0.6.0)
69 72
     em-http-request (1.0.3)
70 73
       addressable (>= 2.2.3)
71 74
       cookiejar
@@ -259,6 +262,7 @@ DEPENDENCIES
259 262
   delayed_job!
260 263
   delayed_job_active_record (~> 0.3.3)
261 264
   devise
265
+  dotenv-rails
262 266
   em-http-request
263 267
   fastercsv
264 268
   foreman

+ 8 - 1
Procfile

@@ -1,4 +1,11 @@
1
+# Procfile for development:
1 2
 web: bundle exec rails server
2 3
 schedule: bundle exec rails runner bin/schedule.rb
3 4
 twitter: bundle exec rails runner bin/twitter_stream.rb
4
-dj: bundle exec script/delayed_job run
5
+dj: bundle exec script/delayed_job run
6
+
7
+# Possible Profile configuration for production:
8
+# web: bundle exec unicorn -c config/unicorn/production.rb
9
+# schedule: bundle exec rails runner bin/schedule.rb
10
+# twitter: bundle exec rails runner bin/twitter_stream.rb
11
+# dj: bundle exec script/delayed_job run

+ 3 - 0
Rakefile

@@ -4,6 +4,9 @@
4 4
 
5 5
 ENV['SKIP_RAILS_ADMIN_INITIALIZER'] = 'true'
6 6
 
7
+require 'dotenv'
8
+Dotenv.load
9
+
7 10
 require File.expand_path('../config/application', __FILE__)
8 11
 
9 12
 Huginn::Application.load_tasks

+ 28 - 16
doc/deployment/capistrano/deploy.rb

@@ -12,11 +12,8 @@ set :deploy_via, :remote_cache
12 12
 set :keep_releases, 5
13 13
 
14 14
 set :bundle_without, [:development]
15
-set :unicorn_pid, "#{shared_path}/pids/unicorn.pid"
16 15
 
17
-server "yourdomain.com", :app, :delayed_job, :web, :db, :primary => true
18
-
19
-set :delayed_job_server_role, :delayed_job
16
+server "yourdomain.com", :app, :web, :db, :primary => true
20 17
 
21 18
 set :sync_backups, 3
22 19
 
@@ -25,24 +22,41 @@ after 'deploy', 'deploy:cleanup'
25 22
 
26 23
 set :bundle_without, [:development, :test]
27 24
 
28
-after 'deploy:stop', 'delayed_job:stop'
29
-after 'deploy:start', 'delayed_job:start'
30
-after 'deploy:restart', 'delayed_job:restart'
31
-after 'deploy:update_code', 'deploy:symlink_env_config'
25
+after 'deploy:update_code', 'deploy:symlink_configs'
26
+after 'deploy:update', 'foreman:export'
27
+after 'deploy:update', 'foreman:restart'
32 28
 
33 29
 namespace :deploy do
34
-  desc 'Link the environment file from shared/config/.env into the new deploy directory'
35
-  task :symlink_env_config, :roles => :app do
30
+  desc 'Link the .env environment and Procfile from shared/config into the new deploy directory'
31
+  task :symlink_configs, :roles => :app do
36 32
     run <<-CMD
37 33
       cd #{latest_release} && ln -nfs #{shared_path}/config/.env #{latest_release}/.env
34
+      cd #{latest_release} && ln -nfs #{shared_path}/config/Procfile #{latest_release}/Procfile
38 35
     CMD
39 36
   end
40 37
 end
41 38
 
42
-# If you want to use command line options, for example to start multiple workers,
43
-# define a Capistrano variable delayed_job_args:
44
-#
45
-#   set :delayed_job_args, "-n 2"
39
+namespace :foreman do
40
+  desc "Export the Procfile to Ubuntu's upstart scripts"
41
+  task :export, :roles => :app do
42
+    run "cd #{latest_release} && rvmsudo bundle exec foreman export upstart /etc/init -a #{application} -u #{user} -l #{deploy_to}/upstart_logs"
43
+  end
44
+
45
+  desc 'Start the application services'
46
+  task :start, :roles => :app do
47
+    sudo "sudo start #{application}"
48
+  end
49
+
50
+  desc 'Stop the application services'
51
+  task :stop, :roles => :app do
52
+    sudo "sudo stop #{application}"
53
+  end
54
+
55
+  desc 'Restart the application services'
56
+  task :restart, :roles => :app do
57
+    run "sudo start #{application} || sudo restart #{application}"
58
+  end
59
+end
46 60
 
47 61
 # If you want to use rvm on your server and have it maintained by Capistrano, uncomment these lines:
48 62
 #   set :rvm_ruby_string, '1.9.3-p286@huginn'
@@ -55,6 +69,4 @@ end
55 69
 Dir[File.expand_path("../../lib/capistrano/*.rb", __FILE__)].each{|f| load f }
56 70
 
57 71
 require "bundler/capistrano"
58
-require "capistrano-unicorn"
59
-require "delayed/recipes"
60 72
 load 'deploy/assets'